﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Dx.Common
{
    /// <summary>
    /// IWin32Window接口类，为了实现弹出的窗体在Word内
    /// </summary>
    public class IntPtrShow : IWin32Window
    {
        private IntPtr m_Handle;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="handle"></param>
        public IntPtrShow(IntPtr handle)
        {
            m_Handle = handle;
        }
        /// <summary>
        /// 构造函数，参数是父窗口的句柄
        /// </summary>
        /// <param name="handle"></param>
        public IntPtrShow(int handle)
        {
            m_Handle = new IntPtr(handle);
        }
        public IntPtr Handle
        {
            get { return m_Handle; }
        }
        //打开窗体，Show参数使用该类自身
        public void Show(Form frm)
        {
            frm.Show(this);
        }
        /// <summary>
        /// 模式打开窗体，Show参数使用该类自身
        /// </summary>
        /// <param name="frm"></param>
        /// <returns></returns>
        public DialogResult ShowDialog(Form frm)
        {
            return frm.ShowDialog(this);
        }
    }
}
